extends Area2D

var rate :Vector2 = Vector2(200,-200)

var init_position :Vector2

signal player_score(player_num)

# Called when the node enters the scene tree for the first time.
func _ready():
	init_position = self.position
	add_to_group("ball")

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta):
	self.position += rate * delta
 
func reset():
	if rate.x > 0:
		player_score.emit(1)
	else:
		player_score.emit(2)

	self.position = init_position

func pong():
	var sound = get_node("SoundPong")
	sound.play()

func pongwall():
	var sound = get_node("SoundPongWall")
	sound.play()

func reverseX():
	rate.x *= -1
	
func reverseY():
	rate.y *= -1
